{% extends "blog/base.html" %}

{% load i18n %}
{% load wiki %}
{% load markup %}
{% load switchcase %}
{% load tagging_tags %}
{% load restructuredtext %}

{% block head_title %}{% blocktrans %}Your Blog Posts{% endblocktrans %}{% endblock %}

{% block extra_head %}
    <link rel="alternate" type="application/atom+xml" title="Blog Post Feed for All Users" href="/feeds/posts/all/" />
    <link rel="alternate" type="application/atom+xml" title="Blog Post Feed for User {{ user.username }}" href="/feeds/posts/only/{{ user.username }}/" />
{% endblock %}

{% block body %}
    <h1>{% trans "Your Posts" %}</h1>

    {% if blogs %}
        <table cellpadding="5" cellspacing="0" border="0" class="blog-list" width="100%">
            <th>Title</th>
            <th>Teaser</th>
            <th>Published On</th>
            <th>Status</th>
            <th></th>
        {% for blogs in blogs %}
            <tr class="{% cycle odd,even %}">
                <td><b><a href="{{ blogs.get_absolute_url }}">{{ blogs.title }}</a></b><br />
                    {% with blogs.tease|truncatewords:"50" as body %}
                        {% switch blogs.markup %}
                            {% case 'rst' %} {{ body|restructuredtext|wikiwords|safe }} {% endcase %}
                            {% case 'mrk' %} {{ body|force_escape|markdown|wikiwords }} {% endcase %}
                            {% case 'txl' %} {{ body|force_escape|textile|wikiwords }} {% endcase %}
                            {% case '' %} {{ body|force_escape|wikiwords|linebreaks|safe }} {% endcase %}
                        {% endswitch %}
                    {% endwith %}
                </td>
                <td nowrap>{{ blogs.publish|date }}</td>
                <td>
                    {% with blogs.status as status %}
                        {% switch status %}
                            {% case 2 %} Published {% endcase %}
                            {% case 1 %} Draft {% endcase %}
                        {% endswitch %}
                    {% endwith %}
                </td>
                <td width="50px" align="center">
                    <form action="{% url blog_edit blogs.id %}" method="GET">
                            <input type="image" src="/site_media/pencil.png" border="0" title="{% trans "Edit Post" %}" />
                    </form>
                </td>
                <td align="right">
                    <form action="{% url blog_destroy blogs.id %}" method="POST">
                        <input type="image" src="/site_media/delete.png" border="0" title="{% trans "Delete Post" %}" />
                        <input type="hidden" name="action" value="delete"/>
                   </form>
                </td>
            </tr>
        {% endfor %}
        </table>
    {% else %}
        No blog posts yet.
    {% endif %}

{% endblock %}
